package dongchel.vrp.entity;

import java.beans.Beans;

import com.sun.corba.se.impl.logging.UtilSystemException;


public class City {
	//static information
	private int id;
	private double x;
	private double y;
	private double etime;
	private double ltime;
	
	private double serviceTime;
	private double demand;
	
	//dynamic information
	private double arrivalTime;
	private double waitingTime;
	private double startTime;
	private double finishTime;
	
	//information related to route
	private Route route;
	
	private double angle;
	
	
	//attribute for pd city
	//type 0: general city type 1: pd city
	private int type;
	
	private double etime2;
	private double ltime2;
	
	private double pickupDemand;
	private double deliveryDemand;
	
	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public double getEtime2() {
		return etime2;
	}

	public void setEtime2(double etime2) {
		this.etime2 = etime2;
	}

	public double getLtime2() {
		return ltime2;
	}

	public void setLtime2(double ltime2) {
		this.ltime2 = ltime2;
	}

	public double getPickupDemand() {
		return pickupDemand;
	}

	public void setPickupDemand(double pickupDemand) {
		this.pickupDemand = pickupDemand;
	}

	public double getDeliveryDemand() {
		return deliveryDemand;
	}

	public void setDeliveryDemand(double deliveryDemand) {
		this.deliveryDemand = deliveryDemand;
	}

	public double getAngle() {
		return angle;
	}

	public void setAngle(double angle) {
		this.angle = angle;
	}

	public City(){}
	
	//get the clone of this city
	public City clone(){	
		// TODO Auto-generated method stub
		City c = new City();
		
		c.setType(type);
		
		c.setEtime(this.getEtime());
		c.setId(this.getId());
		c.setRoute(this.getRoute());		
		c.setServiceTime(this.getServiceTime());
		c.setX(this.getX());
		c.setY(this.getY());
		c.setLtime(this.getLtime());
		c.setArrivalTime(this.getArrivalTime());	
		c.setAngle(this.getAngle());
		c.setDemand(demand);
		
		//for pd city
		c.setPickupDemand(pickupDemand);
		c.setDeliveryDemand(deliveryDemand);
		c.setEtime2(etime2);
		c.setLtime2(ltime2);
		
		return c;		
	}
	

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public double getX() {
		return x;
	}

	public void setX(double x) {
		this.x = x;
	}

	public double getY() {
		return y;
	}

	public void setY(double y) {
		this.y = y;
	}

	public double getEtime() {
		return etime;
	}

	public void setEtime(double etime) {
		this.etime = etime;
	}

	public double getLtime() {
		return ltime;
	}

	public void setLtime(double ltime) {
		this.ltime = ltime;
	}

	public double getServiceTime() {
		return serviceTime;
	}

	public void setServiceTime(double serviceTime) {
		this.serviceTime = serviceTime;
	}

	public double getArrivalTime() {
		return arrivalTime;
	}

	public void setArrivalTime(double arrivalTime) {
		this.arrivalTime = arrivalTime;
		this.waitingTime = Math.max(this.etime-arrivalTime, 0);
		this.startTime = Math.max(this.etime, arrivalTime);
		this.finishTime = this.startTime + this.serviceTime;
	}

	public double getWaitingTime() {
		return waitingTime;
	}

	public void setWaitingTime(double waitingTime) {
		this.waitingTime = waitingTime;
	}

	public double getStartTime() {
		return startTime;
	}

	public void setStartTime(double startTime) {
		this.startTime = startTime;
	}

	public double getFinishTime() {
		return finishTime;
	}

	public void setFinishTime(double finishTime) {
		this.finishTime = finishTime;
	}

	public Route getRoute() {
		return route;
	}

	public void setRoute(Route route) {
		this.route = route;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final City other = (City) obj;
		if (id != other.id)
			return false;
		return true;
	}

	public double getDemand() {
		return demand;
	}

	public void setDemand(double demand) {
		this.demand = demand;
	}
	
	public String toString(){
		return String.valueOf(this.id);
	}
}
